package com.example.job;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @Description: 全局异常捕获处理
 * @Auther: Swain
 * @Date: 2021/1/11 16:48
 * @Version 1.0.0
 */
@Component
public class DemoJob {

    private static final Logger logger;

    static {
        logger = LoggerFactory.getLogger(DemoJob.class);
    }

    private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

//    @Scheduled(fixedRate = 10000)//10s触发一次
    public void reportCurrentTime() {
        logger.info("定时任务执行 当前时间：{}", dateFormat.format(new Date()));
    }
}
